<%# locals: (text:, type: "primary", link: nil, icon: nil, attributes: {}, extra_class: nil, right_icon: nil) %>
<% color = BUTTON_COLOR[type] %>

<% if link %>
  <a
    href="<%= link %>"
    class="inline-flex items-center justify-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 <%= color %> disabled:pointer-events-none disabled:opacity-50 <%= extra_class %>"
    <% attributes.each do |atr_key, atr_value| %>
    <%= atr_key %>="<%= atr_value %>"
    <% end%>
  >
    <% if icon %>
      <%== part("components/icon", name: icon, classes: "h-5 w-5") %>
    <% end %>
    <%= text %>
  </a>
<% else %>
  <button
    class="inline-flex items-center justify-center rounded-md px-3 py-2 text-sm font-semibold text-white shadow-sm focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 <%= color %> disabled:pointer-events-none disabled:opacity-50 <%= extra_class %>"
    <% attributes.compact.each do |atr_key, atr_value| %>
    <%= atr_key %>="<%= atr_value %>"
    <% end%>
  >
    <% if icon %>
      <%== part("components/icon", name: icon, classes: "h-5 w-5 #{(text && !text.empty?) ? "ml-0.5 mr-1.5" : "mx-0"}") %>
    <% end %>
    <%= text %>
    <% if right_icon %>
      <%== part("components/icon", name: right_icon, classes: "ml-1.5 -mr-1 h-5 w-5") %>
    <% end %>
  </button>
<% end %>
